from django.shortcuts import render

# Create your views here.
from rest_framework.views import APIView
from rest_framework.response import Response
from .models import SQLiteDB

#任务下次运行时间
class JobNextRunTimeAPIView(APIView):
    def get(self,request):
        db = SQLiteDB()
        data = db.fetch_all_next_run_time()
        db.close()
        ret = {
            'code':200,
            'status':'success',
            'data':data,
        }
        return Response(ret)

#任务最近运行历史
class JobRunTimeHistory(APIView):
    def get(self,request):
        db = SQLiteDB()
        data = db.fetch_all_run_history()
        db.close()
        ret = {
            'code':200,
            'status':'success',
            'data':data
        }
        return Response(ret)

#任务最近运行错误
class JobRunErrorHistory(APIView):
    def get(self,request):
        db = SQLiteDB()
        data = db.fetch_all_error_history()
        db.close()
        ret = {
            'code': 200,
            'status': 'success',
            'data': data
        }
        return Response(ret)